<template>
  <div class="tab-btn height-52">
    <ul class="flex font-16 font-white height-per-100">
      <li class="v-align-c" :class="activeIndex === index ? 'active-tab' : ''" v-for="(item, index) of tabName" :key="index" @click="changeTab(index)">{{item}}</li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tabName: ['销售额排名', '销量排名', '退款率排名'],
      activeIndex: 0,
      sortType: 2 // 排序方式 1：按销量排序 2：按销售额排序 3：退款率
    }
  },
  methods: {
    changeTab(index) {
      this.activeIndex = index
      switch (index) {
        case 0:
          this.sortType = 2
          break
        case 1:
          this.sortType = 1
          break
        case 2:
          this.sortType = 3
          break
      }
      this.$bus.$emit('getSortType', this.sortType)
      this.$emit('getSortText', this.tabName[index])
    }
  }
}
</script>

<style  rel="stylesheet/scss" lang="scss" scoped>
  .tab-btn {
    width: 100%;
    background: #2B2B2E;
    border:1px solid #646469;
    color: #fff;
    padding-left: 24px;
    ul {
      list-style: none;
      padding: 0;
      margin: 0;
      &>li{
        height: 100%;
        position: relative;
      }
      &>li:hover{
          cursor:pointer
        }
      &>li:not(:first-child) {
        margin-left: 91px;
      }
      .active-tab::after {
        content: '';
        display: block;
        width: 68px;
        height: 2px;
        position: absolute;
        background: #2750FF;
        left: 50%;
        margin-left: -34px;
        bottom: 0;
      }
    }
  }
</style>